/**
 * @BelongsProject : LeetCode
 * @Author : WXY
 * @CreateTime : 2022-12-08  19:17
 * @Description :剑指 Offer 27. 二叉树的镜像
 * @Version : 1.0
 */

public class Num027_mirrorTree {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }
    public static TreeNode mirrorTree(TreeNode root) {
        if (root == null)  return null;
        TreeNode leftRoot = root.left;
        TreeNode rightRoot = root.right;
        root.left = rightRoot;
        root.right = leftRoot;
        mirrorTree(root.left);
        mirrorTree(root.right);
        return root;
    }
}
